package cn.lyn4ever.goods.web.controller;

import cn.lyn4ever.common.R;
import cn.lyn4ever.goods.web.service.ProductTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 这个是商品的类型表，还是要有分级的(ProductType)表控制层
 *
 * @author makejava
 * @since 2020-03-26 22:55:32
 */
@Api( description = "商品分类接口")
@RestController
@RequestMapping("productType")
public class ProductTypeController {
    /**
     * 服务对象
     */
    @Resource
    private ProductTypeService productTypeService;

    /**
     * 获取一级分类
     * @return
     */
    @ApiOperation(value = "获取一级分类", notes = "获取一级分类")
    @GetMapping("getProductTypeLevel1")
    public R getProductTypeLevel1(){

        return R.ok("获取成功").put("data",this.productTypeService.getProductTypeLevel1());
    }

    /**
     *获取二级分类
     *
     * @param sjid 上级id（一级分类id）
     * @return
     */
    @ApiOperation(value = "获取二级分类", notes = "根据上级id获取二级分类")
    @GetMapping("getProductTypeLevel2")
    @ApiImplicitParam(name = "sjid", value = "1",required = true, dataType = "string", paramType = "query", defaultValue = "1")
    public R getProductTypeLevel2(Integer sjid){

        return R.ok("获取成功").put("data",this.productTypeService.getProductTypeLevel2(sjid));
    }


}